<?php
namespace app\index\controller;

/*验证登录*/


use app\admin\controller\Admin;
use app\common\Rsa;
use app\member\controller\db\Member;
use think\Request;

class CheckAll
{
    /*登录验证*/
    public function checkLogin($account, $password, Request $request){
            $code = new Code();
            /*RSA私钥解密*/
            if($code->checkCode()){
//            if(true){
                $admin = new Admin();
                $member = new Member();
                $password = Rsa::privDecrypt($password);
                $data = $admin->selectPassword($account);
                $memberData = $member->selectByName($account);
                $memberEmail = $member->selectByEmail($account);
                if($account == "admin" && $password == $data['admin_password']){
                    /*管理员用户*/
                    return "1";
                }
                if($account != "admin"
                    &&(
                        ($password == $memberData["member_password"])
                        ||$password == $memberEmail["member_password"])
                    ){
                    /*普通用户*/
                    return "2";
                }
            }else{
                /*验证码错误*/
                return "-1";
            }
    }

    /*-----------------------------注册请求---------------------------------*/
    /*
     *
     *
     *
     * */

    public function checkRegister(){

        return true;
    }

}